package com.kurumi.query;

import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.kurumi.util.StringUtil;

public class MedicalRecordScanQuery extends PageQuery{

		//病案唯一标识
		private String onlyId;

		//患者姓名
		private String patientName;
		
		//证件类型编号
		private String idDocumentTypeCode;
		
		//证件号
		private String idNumber;
		
		//出院开始时间
		@DateTimeFormat(pattern="yyyy-MM-dd")
		@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
		private Date outHospitalStartDate;
		
		//出院结束时间
		@DateTimeFormat(pattern="yyyy-MM-dd")
		@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
		private Date outHospitalEndDate;
		
		//病案号
		private String mrId;
		
		//出院科室编号
		private String outDeptCode;
		
		
		//示踪开始时间
		@DateTimeFormat(pattern="yyyy-MM-dd")
		@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
		private Date scanStartDate;
		
		//示踪结束时间
		@DateTimeFormat(pattern="yyyy-MM-dd")
		@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
		private Date scanEndDate;
		//状态
		private String scanStatus;
		
		//查询结果集
		private Object queryDatas;
		
		public String getOnlyId() {
			return StringUtil.meaningStr(onlyId);
		}
		public void setOnlyId(String onlyId) {
			this.onlyId = onlyId;
		}
		public String getPatientName() {
			return StringUtil.meaningStr(patientName);
		}
		public void setPatientName(String patientName) {
			this.patientName = patientName;
		}

		public String getIdDocumentTypeCode() {
			return StringUtil.meaningStr(idDocumentTypeCode);
		}

		public void setIdDocumentTypeCode(String idDocumentTypeCode) {
			this.idDocumentTypeCode = idDocumentTypeCode;
		}
		public String getIdNumber() {
			return StringUtil.meaningStr(idNumber);
		}

		public void setIdNumber(String idNumber) {
			this.idNumber = idNumber;
		}
		public Date getOutHospitalStartDate() {
			return outHospitalStartDate;
		}
		public void setOutHospitalStartDate(Date outHospitalStartDate) {
			this.outHospitalStartDate = outHospitalStartDate;
		}

		public Date getOutHospitalEndDate() {
			return outHospitalEndDate;
		}

		public void setOutHospitalEndDate(Date outHospitalEndDate) {
			this.outHospitalEndDate = outHospitalEndDate;
		}

		public String getMrId() {
			return StringUtil.meaningStr(mrId);
		}
		public void setMrId(String mrId) {
			this.mrId = mrId;
		}

		
		
		public String getOutDeptCode() {
			return StringUtil.meaningStr(outDeptCode);
		}
		public void setOutDeptCode(String outDeptCode) {
			this.outDeptCode = outDeptCode;
		}
		public Date getScanStartDate() {
			return scanStartDate;
		}
		public void setScanStartDate(Date scanStartDate) {
			this.scanStartDate = scanStartDate;
		}
		public Date getScanEndDate() {
			return scanEndDate;
		}
		public void setScanEndDate(Date scanEndDate) {
			this.scanEndDate = scanEndDate;
		}
		public String getScanStatus() {
			return StringUtil.meaningStr(scanStatus);
		}
		public void setScanStatus(String scanStatus) {
			this.scanStatus = scanStatus;
		}
		public Object getQueryDatas() {
			return queryDatas;
		}
		public void setQueryDatas(Object queryDatas) {
			this.queryDatas = queryDatas;
		}
		
		@JsonIgnore
		public Boolean isEmpty(){
			DealDate();
			if(this.getOnlyId() == null && this.getMrId() == null &&this.getPatientName() == null 
					&& this.getOutHospitalStartDate() == null && this.getOutHospitalEndDate() == null
					&& this.getIdNumber() == null&&  this.getOutDeptCode() == null
					&& this.getScanStartDate() == null && this.getScanEndDate() == null){
				return true;
			}
			return false;
		}
		
		
		private void DealDate(){
			if(this.getOutHospitalStartDate() == null && this.getOutHospitalEndDate() != null){
				this.setOutHospitalStartDate(this.getOutHospitalEndDate());
			}else if(this.getOutHospitalStartDate() != null && this.getOutHospitalEndDate() == null){
				this.setOutHospitalEndDate(this.getOutHospitalStartDate());
			}
			
			if(this.getScanStartDate() == null && this.getScanEndDate() != null){
				this.setScanStartDate(this.getScanEndDate());
			}else if(this.getScanStartDate() != null && this.getScanEndDate() == null){
				this.setScanEndDate(this.getScanStartDate());
			}
			
		}
}
